<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <link rel="stylesheet" href="css/eui.css">
  <style>
    body {

      background-image: url("../static/image/背景图片.webp");
      margin: 0;
      background-size: cover; /*cover是专门用来设置全屏背景的*/
      text-align: center;
    }
  </style>
</head>
<body>
<h1>注册页面</h1>
<div id="app">
  <el-card style="width: 600px;height: 300px;
    margin: 0 auto;background-color: rgba(255,255,255,0.3)">
    <el-form style="width: 400px;margin: 30px auto" label-width="60px" >
      <el-form-item label="用户名">
        <el-input type="text" v-model="user.username" placeholder="请输入用户名"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input type="password" v-model="user.password" placeholder="请输入密码"></el-input>
      </el-form-item>
      <el-form-item label="昵称">
        <el-input type="text" v-model="user.nick" placeholder="请输入昵称"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button style="position: relative;right: 35px" type="primary" @click="reg()">注册</el-button>
      </el-form-item>
    </el-form>
  </el-card>
</div>
<script src="js/vue.js"></script>
<script src="js/eui.js"></script>
<script src="js/axios.min.js"></script>
<script>
  let v = new Vue({
    el:"div",
    data:{
      user:{
        username:"",
        password:"",
        nick:""
      }
    },
    methods:{
      reg(){
        //发出注册请求
        axios.post("/reg",v.user).then(function (response) {
          if (response.data==1){
            alert("注册成功!");
            location.href="/login.html";
          }else{
            alert("用户名已存在!");
          }

        })
      }
    }
  })
</script>
</body>
</html>